package com.chant.startFarming.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chant.startFarming.entity.Ranches;
import com.chant.startFarming.mapper.RanchesMapper;
import com.chant.startFarming.service.IRanchesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 牧场表，存储牧场的基本信息和状态 服务实现类
 * </p>
 *
 * @author chant
 * @since 2025-03-31
 */
@Service
public class RanchesServiceImpl extends ServiceImpl<RanchesMapper, Ranches> implements IRanchesService {
    @Override
    public List<Ranches> searchRanches(String name, Integer ranchesStatus) {
        QueryWrapper<Ranches> queryWrapper = new QueryWrapper<>();
        if (name != null && !name.isEmpty()) {
            queryWrapper.like("name", name);
        }
        if (ranchesStatus != null) {
            queryWrapper.eq("ranches_status", ranchesStatus);
        }
        return this.list(queryWrapper);
    }
}
